package z_exam;

import java.util.Arrays;

/**
 * @Author: 海琳琦
 * @Date: 2022/4/7 19:28
 */

public class Test8 {

    public static void main(String[] args) {
        int[] arr = {0, 3, 7, 2, 5, 8, 4, 6, 0, 1};
        Arrays.sort(arr);
        //dp[i]表示最长连续子序列的长度
        int n = arr.length;
        int[] dp = new int[n];
        Arrays.fill(dp, 1);
        int[] left = new int[n];
        int[] right = new int[n];
        for (int i = 0; i < n; i++) {
            left[i] = i;
            right[i] = i;
        }
        int max = 1;
        int index = 0;
        for (int i = 1; i < n; i++) {
            //连续
            if (arr[i] - arr[i - 1] == 1) {
                dp[i] = dp[i - 1] + 1;
                left[i] = left[i - 1];
                if (dp[i] > max) {
                    max = dp[i];
                    index = i;
                }
            }
        }
        System.out.println(arr[left[index]] + " " + arr[right[index]]);
    }
}


